package com.achf.siap.cd.entidade.dicionario;

import com.achf.siap.cd.entidade.base.Entidade;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 *
 * @author Aureliano
 */
@Entity
@Table(schema="siap", name="sistema_humano")
public class SistemaHumano implements Entidade {

    @Id
    @SequenceGenerator(name="sistema_humano_seq")
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="sistema_humano_seq")
    @Column(name="id", nullable=false)
    private Long id;

    @Column(name="sistema", nullable=false, length=100, unique=true)
    private String sistema;

    @Column(name="descricao", nullable=false, length=300)
    private String descricao;

    @OneToMany(
        targetEntity=SinalSintoma.class, mappedBy="sistemaHumano",
        cascade={CascadeType.ALL}, fetch=FetchType.LAZY, orphanRemoval=true
    )
    private List<SinalSintoma> sinaisSintomas;

    public SistemaHumano() {
        super();
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getDescricao() {
        return descricao;
    }

    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    public String getSistema() {
        return sistema;
    }

    public void setSistema(String sistema) {
        this.sistema = sistema;
    }

    public List<SinalSintoma> getSinaisSintomas() {
        return sinaisSintomas;
    }

    public void setSinaisSintomas(List<SinalSintoma> sinalSintomas) {
        this.sinaisSintomas = sinalSintomas;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final SistemaHumano other = (SistemaHumano) obj;
        if ((this.sistema == null) ? (other.sistema != null) : !this.sistema.equals(other.sistema)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 43 * hash + (this.sistema != null ? this.sistema.hashCode() : 0);
        return hash;
    }
}